// pages/game/index.js

const data = require('../../data/question.js');
var len=3;   //题量
var index=1;  //题号
var q=[];     //题库数组
var a=[];     //题库的答案
var anchar = "";  //当前缺的字
var toAnswer = "";  //生成的答案
Page({ 
  data: {

  },

  //生成答案，随机某一个字
  makeAnswer: function () {    
    for(var j=0;j<q.length;j++){
      var i = (Math.floor(Math.random() * 1000)) % (q[j].confirm.length);
      a.push(q[j].confirm.substr(i, 1));      
    }
  },

  
  onLoad: function (options) {
    var words = data.myQuestions.answer;
    console.log(words)

    var questions = data.myQuestions.data
    console.log(questions)

    //随机出题
    for(var i=0;i<len;i++)
    {
      index=Math.ceil((Math.random()+0.01)*(questions.length -i));
      console.log(index)
      q.push(questions[index])
    }
    this.makeAnswer(q);

    console.log(q)
    console.log(a)

  }
})